#include <bits/stdc++.h>
using namespace std;
template <typename T>
void readi(T &x)
{
    T f = 1;
    x = 0;
    int ch;
    while (ch = getchar(), !feof(stdin) && !isdigit(ch) && ch != '-')
        ;
    if (ch == '-')
        f = -f, ch = getchar();
    while (!feof(stdin) && isdigit(ch))
    {
        x = (x << 3) + (x << 1) + ch - 0x30;
        ch = getchar();
    }
    x *= f;
}
template <typename T>
void writei(T x)
{
    if (x == 0)
    {
        putchar('0');
        return;
    }
    if (x < 0)
        x = -x, putchar('-');
    T p = 1;
    while (x / p >= 10)
        p = (p << 3) + (p << 1);
    while (p)
    {
        putchar(x / p + 0x30);
        x %= p;
        p /= 10;
    }
}
class Car
{
public:
    int l, r;
    bool operator<(const Car &car)
    {
        return this->r < car.r || (this->r == car.r && this->l < car.l);
    }
};
const int MAXN = 1e5 + 7;
int T;
int n, m, L, V, tot;
Car car[MAXN];
int p[MAXN];
const int MAXL = 1e6 + 7;
int ap[MAXL];
void solve()
{
    readi(n);
    readi(m);
    readi(L);
    readi(V);
    tot = 0;
    for (int i = 1; i <= n; i++)
    {
        int d, v, a;
        readi(d);
        readi(v);
        readi(a);
        if (a == 0)
        {
            if (v > V)
            {
                tot++;
                car[tot].l = d,
                car[tot].r = L;
            }
        }
        else if (a < 0)
        {
            if (v > V)
            {
                tot++;
                car[tot].l = d;
                car[tot].r = min(car[tot].l + (v * v - V * V) / (2 * (-a)) - ((v * v - V * V) % (2 * (-a)) == 0), L);
            }
        }
        else
        {
            if (v * v + 2 * a * (L - d) > V * V)
            {
                tot++;
                car[tot].r = L;
                if (v > V)
                    car[tot].l = d;
                else
                    car[tot].l = d + (V * V - v * v) / (a * 2) + 1;
            }
        }
    }
    for (int i = 1; i <= m; i++)
        readi(p[i]);
    p[m + 1] = L + 1;
    p[0] = 0;
    for (int i = 0; i <= m; i++)
        for (int j = p[i]; j < p[i + 1]; j++)
            ap[j] = i;
    int ans_car = 0, ans_camera = 0;
    for (int i = 1; i <= tot; i++)
    {
        if (ap[car[i].l - 1] != ap[car[i].r])
        {
            ans_car++;
            car[ans_car].l = ap[car[i].l - 1] + 1;
            car[ans_car].r = ap[car[i].r];
            // fprintf(stderr, "over speed : [%d, %d]\n", car[i].l, car[i].r);
            // fprintf(stderr, "camera     : [%d, %d]\n", ap[car[i].l - 1] + 1, ap[car[i].r]);
        }
    }
    sort(car + 1, car + ans_car + 1);
    int i = 1;
    while (i <= ans_car)
    {
        ans_camera++;
        int p_camera = car[i].r;
        // cerr << car[i].r << endl;
        while (i <= ans_car && car[i].l <= p_camera)
            i++;
    }
    ans_camera = m - ans_camera;
    writei(ans_car);
    putchar(' ');
    writei(ans_camera);
    putchar('\n');
    return;
}
int main()
{
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    readi(T);
    while (T--)
        solve();
    return 0;
}